<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class Timkiem_giasu extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('display_model');
    }

    function render($path, $data) {
        $this->load->view('user/common/header_view');
        $this->load->view('user/common/left_sidebar_view');
        $this->load->view('user/common/seach_view_giasu', $data);
        $this->load->view($path, $data);
        $this->load->view('user/common/right_sidebar_view');
        $this->load->view('user/common/footer_view');
    }

    public function getTrinhDo($idTrinhDo) {
        //todo
        return 0;
    }

    public function index() {
        $TenThanhVien = $this->input->post('ten');
        $idTrinhDo = $this->input->post('trinhdo'); //1: Cao đẳng ; 2: Đại học ; 3: Thạc Sỹ
        $idGioiTinh = $this->input->post('gioitinh'); //: khong xác định ; 1: Nam ; 2: Nữ
        if (isset($_POST['option'])) {
            $TenMonHoc = $_POST['option'];
        } else {
            $TenMonHoc = [];
        }

        $this->load->model('timkiem_giasu_model');

        $this->load->library('pagination');
        $config['base_url'] = base_url() . 'index.php/timkiem/timkiem_giasu/index';
        $config['total_rows'] = $this->timkiem_giasu_model->index($TenThanhVien, $idTrinhDo, $idGioiTinh, $TenMonHoc, NULL, NULL);
        $config['per_page'] = 10; //records
        $config['uri_segment'] = 4;
        $config['num_links'] = 10;
        $config['next_link'] = 'Next »';
        $config['prev_link'] = '« Prev';
        $config['full_tag_open'] = '<ul class="pagination">';
        $config['full_tag_close'] = '</ul>';
        $config['prev_tag_open'] = '<li>';
        $config['prev_tag_close'] = '</li>';
        $config['next_link'] = '&raquo;';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="#">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';
        ;

        $this->pagination->initialize($config);

        $data = $this->timkiem_giasu_model->index($TenThanhVien, $idTrinhDo, $idGioiTinh, $TenMonHoc, $config['per_page'], $this->uri->segment(4));
//        /timkiem/timkiem_giasu_model($TenThanhVien,$idTrinhDo,$idGioiTinh,$TenMonHoc)
        $data['data'] = $data;
        $data['link'] = $this->pagination->create_links();
        //get TrinhDo
        $TrinhDo = $this->timkiem_giasu_model->getTrinhDo();
        $data['TrinhDo'] = $TrinhDo;
        //get NganhHoc
        $NganhHoc = $this->timkiem_giasu_model->getNganhHoc();
        $data['NganhHoc'] = $NganhHoc;
        //get Monhoc
        $MonHoc = $this->timkiem_giasu_model->getMonHoc();
        $data['MonHoc'] = $MonHoc;

        $data['iten'] = $TenThanhVien;
        $data['itrinhdo'] = $idTrinhDo;
        if ($idGioiTinh == NULL)
            $data['igioitinh'] = '';
        else
            $data['igioitinh'] = $idGioiTinh;
        $data['imonhoc'] = $TenMonHoc;

        $data['path'] = 'timkiem/timkiem_giasu';
        $this->render('timkiem/timkiem_giasu_view', $data);
    }

}

?>
